﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Alignmentizer
{
	class Program
	{
		static void Main(string[] args)
		{

			if (args.Length == 0)
			{
				Console.WriteLine("Please specifiy a file contianing sequences.");
				Console.Read();
				Environment.Exit(0);
			}
			//string st1 = "GAATTCAGTTA";
			//string st2 = "GGATCGA";
			string[] sequences;
			int match=0, mismatch=0, gap=0;
			Nullable<int> input;
			bool global;

			string scoringMatrixPath = "";// = "C:\\Users\\userMehdi\\Documents\\visual studio 2012\\Projects\\Alignmentizer\\scoring matrix.txt";

			sequences = HelperFunctions.ImportSequence(args[0], 2);
			//if there are 2 arguments 2nd one should be scoring matrix
			if (args.Length == 2)
			{
				scoringMatrixPath = args[1];
				//Dictionary<string, int> scoringMatrix = HelperFunctions.ImportScoringMatrix(scoringMatrixPath);
				
			}


			#region Get score values from the user
			if (scoringMatrixPath == "")
			{
				global = true;
				Console.Write("Dynamic Programming Alignmentizer!\n");
				Console.Write("Points for match (default +5): ");
				input = HelperFunctions.GetNumericInput();
				if (input != null)
					match = input.Value;
				else
					match = 5;

				Console.Write("Points for mismatch (default -3): ");
				input = HelperFunctions.GetNumericInput();
				if (input != null)
					mismatch = input.Value;
				else
					mismatch = -3;

				Console.Write("Points for gap (default -4): ");
				input = HelperFunctions.GetNumericInput();
				if (input != null)
					gap = input.Value;
				else
					gap = -4;
			}
			else
			{
				Console.WriteLine("Scoring Matrix specified, performing locally optimized alignmnet.\n");
				global = false;
			}

			#endregion
			
			Console.WriteLine("Sequence 1: {0}\nSequence 2: {1}\n", sequences[0], sequences[1]);
			Console.WriteLine("Aligned Sequences:\n");
			Matrix matrix = new Matrix(sequences[0], sequences[1], match, mismatch, gap, global, scoringMatrixPath);

			
			//matrix.MatrixFill(false);
			//matrix.TraceBack();
			Console.Read();
			//I LIKE HAIRY BALLS....in my mouth. YUM
		}
	}
}
